"use strict";
cc._RF.push(module, '69cdetEISRLoYxGWYk51AP6', 'logScreen');
// scripts/O1ModuleRes/frame/logScreen.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var btButton_1 = require("../control/btButton");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var logScreen = /** @class */ (function (_super) {
    __extends(logScreen, _super);
    function logScreen() {
        // LIFE-CYCLE CALLBACKS:
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.ndUiLayer = null;
        _this.btShowHide = null;
        _this.ndList = null;
        _this.ndText = null;
        _this.sOpacity = null;
        _this.maxCount = 1000;
        _this.m_newFps = false;
        return _this;
    }
    //
    logScreen.prototype.addLog = function (text, colorLoop) {
        var _this = this;
        //
        var str = text;
        var newText = cc.instantiate(this.ndText);
        this.ndList.addChild(newText);
        newText.color = colorLoop;
        newText.getComponent(cc.Label).string = str;
        //
        if (this.ndList.childrenCount > this.maxCount) {
            for (var i = 0; i < this.maxCount / 2; i++) {
                this.ndList.children[i].destroy();
            }
        }
        this.m_newFps = true;
        //
        this.unscheduleAllCallbacks();
        this.scheduleOnce(function () {
            _this.onScrollDown();
        });
    };
    logScreen.prototype.onLoad = function () {
    };
    logScreen.prototype.start = function () {
        cc.game.addPersistRootNode(this.node);
    };
    logScreen.prototype.onScrollUp = function (isOnce) {
        if (this.ndList.height < this.node.height)
            return;
        //
        var top = this.node.height / 2;
        //
        if (isOnce) {
            top = Math.max(top, this.ndList.y - this.node.height * 0.15);
        }
        //
        cc.tween(this.ndList)
            .to(0.5, { y: top }, { easing: 'cubicOut' /*'cubicOut'*/ })
            .start();
    };
    logScreen.prototype.onScrollDown = function (isOnce) {
        if (this.ndList.height < this.node.height)
            return;
        //
        var top = this.node.height / 2;
        var down = top + (this.ndList.height - this.node.height);
        //
        if (isOnce) {
            down = Math.min(down, this.ndList.y + this.node.height * 0.15);
        }
        //
        cc.tween(this.ndList)
            .to(0.5, { y: down }, { easing: 'cubicOut' })
            .start();
        //
    };
    logScreen.prototype.onBtnUp = function () {
        if (this.ndList.height < this.node.height)
            return;
        this.onScrollUp(true);
    };
    logScreen.prototype.onBtnDown = function () {
        if (this.ndList.height < this.node.height)
            return;
        this.onScrollDown(true);
    };
    logScreen.prototype.onBtnShowHide = function () {
        this.ndList.active = !this.ndList.active;
        this.ndUiLayer.active = !this.ndUiLayer.active;
        this.btShowHide.setButtonText(this.ndList.active ? '隐' : '显');
        if (this.ndList.active) {
            this.onScrollDown();
        }
    };
    logScreen.prototype.onBtnClear = function () {
        this.ndList.destroyAllChildren();
    };
    logScreen.prototype.onSetOpacity = function () {
        this.ndList.opacity = 20 + this.sOpacity.progress * (255 - 20);
    };
    logScreen.prototype.update = function (dt) {
        if (this.m_newFps) {
            this.onScrollDown();
        }
        this.m_newFps = false;
    };
    __decorate([
        property(cc.Node)
    ], logScreen.prototype, "ndUiLayer", void 0);
    __decorate([
        property(btButton_1.default)
    ], logScreen.prototype, "btShowHide", void 0);
    __decorate([
        property(cc.Node)
    ], logScreen.prototype, "ndList", void 0);
    __decorate([
        property(cc.Node)
    ], logScreen.prototype, "ndText", void 0);
    __decorate([
        property(cc.Slider)
    ], logScreen.prototype, "sOpacity", void 0);
    __decorate([
        property()
    ], logScreen.prototype, "maxCount", void 0);
    logScreen = __decorate([
        ccclass
    ], logScreen);
    return logScreen;
}(cc.Component));
exports.default = logScreen;

cc._RF.pop();